﻿using System;

namespace MiniFox.Infrastructure.Attributes
{
    /// <summary>
    /// 修饰属性，以指示在生成lambda 表达式时，对应的实体类型的字段
    /// </summary>
    [AttributeUsage(AttributeTargets.Property)]
    public sealed class TargetPropertyAttribute : Attribute
    {
        string _propertyName;
        QueryOperation _operation;
        bool _ignoreNull;

        /// <summary>
        /// 
        /// </summary>
        /// <param name="propertyName"></param>
        /// <param name="operation"></param>
        public TargetPropertyAttribute(string propertyName, QueryOperation operation) : this(propertyName, operation, true)
        {
        }
        /// <summary>
        /// 
        /// </summary>
        /// <param name="propertyName"></param>
        /// <param name="operation">操作符</param>
        /// <param name="ignoreNull">是否忽略空值</param>
        public TargetPropertyAttribute(string propertyName, QueryOperation operation, bool ignoreNull)
        {
            _propertyName = propertyName;
            _operation = operation;
            _ignoreNull = ignoreNull;
        }
        /// <summary>
        /// 
        /// </summary>
        public string PropertyName
        {
            get { return _propertyName; }
            internal set { _propertyName = value; }
        }
        /// <summary>
        /// 操作符
        /// </summary>
        public QueryOperation Operation
        {
            get { return _operation; }
        }
        /// <summary>
        /// 忽略空值
        /// </summary>
        public bool IngoreNull
        {
            get { return _ignoreNull; }
        }
        /// <summary>
        /// 
        /// </summary>
        public StringComparison StringComparison
        {
            get;set;
        } = StringComparison.OrdinalIgnoreCase;
    }
}
